package com.maiji.cloud.controller.shopingmall;


import java.util.List;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.entities.shopingmall.DistributionFundRuleEntity;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.request.shopingmall.DistributionLogListReqDto;
import com.maiji.cloud.request.shopingmall.SubmitApplayReqData;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.login.DistributionSumResDto;
import com.maiji.cloud.response.login.DistributionUserListResDto;
import com.maiji.cloud.response.shopingmall.DistributionAgentApplyInfoResData;
import com.maiji.cloud.response.shopingmall.DistributionLogListResDto;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/distribut/")
@Api(tags = { "分销模块" })
public class DistributionController extends BaseController{
	/**
	 * 获取一、二级用户的佣金比例
	 * @return
	 */
	@PostMapping("getCommissionRate")
	@ApiOperation(value = "获取一、二级用户的佣金比例")
	public BaseDataResDto<List<DistributionFundRuleEntity>> getCommissionRate(@RequestHeader("maijiToken")String maijiToken){
		
		return postForObjectWithToken(maijiToken,REST_URL_SHOPINGMALL + "/distribution/getCommissionRate", null, BaseDataResDto.class);
	}
	/**
	 * 分销申请信息
	 * @return
	 */
	@PostMapping("getDistributionAgentApplyInfo")
	@ApiOperation(value = "代理申请资料信息及审核状态")
	public BaseDataResDto<DistributionAgentApplyInfoResData> getDistributionAgentApplyInfo(@RequestHeader String maijiToken){
	
		
		return postForObjectWithToken(maijiToken,REST_URL_SHOPINGMALL + "/distribution/getDistributionAgentApplyInfo", null, BaseDataResDto.class);
	}
	
	@ApiOperation(value = "用户申请分销代理")
	@PostMapping("submitApplay")
	public BaseResDto submitApplay(@RequestBody BaseDataReqDto<SubmitApplayReqData> param,
			@RequestHeader("maijiToken")String maijiToken) {
		return postForObjectWithToken(maijiToken,REST_URL_SHOPINGMALL + "/distribution/submitApplay", param, BaseResDto.class);
	}
	/**
	 * 统计分销用户数量
	 * @param param
	 * @param maijiToken
	 * @return
	 */
	@PostMapping("getDistributionSum")
	@ApiOperation(value = "统计分销用户数量")
	public DistributionSumResDto getDistributionSum(@RequestBody DistributionLogListReqDto param, @RequestHeader(name = "maijiToken") String maijiToken) {
		return postForObjectWithToken(maijiToken,REST_URL_APPLOGIN + "/user/getDistributionSum", param, DistributionSumResDto.class);
		
	}
	
	/**
	 * 获取今日分销统计用户列表
	 * @param param
	 * @param maijiToken
	 * @return
	 */
	@PostMapping("getDistributionUserTodayList")
	@ApiOperation(value = "获取今日分销统计用户列表")
	public DistributionUserListResDto getDistributionUserTodayList(@RequestBody DistributionLogListReqDto param, @RequestHeader(name = "maijiToken") String maijiToken){
		return postForObjectWithToken(maijiToken,REST_URL_APPLOGIN + "/user/getDistributionUserTodayList", param, DistributionUserListResDto.class);
	}
	
	/**
	 *获取所有分销统计用户列表
	 * @param param
	 * @param maijiToken
	 * @return
	 */
	@PostMapping("getDistributionUserAllList")
	@ApiOperation(value = "获取所有分销统计用户列表")
	public DistributionUserListResDto getDistributionUserAllList(@RequestBody DistributionLogListReqDto param, @RequestHeader(name = "maijiToken") String maijiToken){
		return postForObjectWithToken(maijiToken,REST_URL_APPLOGIN + "/user/getDistributionUserAllList", param, DistributionUserListResDto.class);
	}
	
	/**
	 * 分销明细列表
	 * @param maijiToken
	 */
	@PostMapping("getDistributionLogList")
	@ApiOperation(value = "分销明细列表")
	public DistributionLogListResDto getDistributionLogList(@RequestBody DistributionLogListReqDto param,@RequestHeader("maijiToken") String maijiToken) {
		return postForObjectWithToken(maijiToken,REST_URL_SHOPINGMALL + "/distribution/getDistributionLogList", param, DistributionLogListResDto.class);
	}
	
}
